<template>
    <div class="alert-container" v-if="show">
        <div class="alert-con">
            {{tip}}
        </div>
    </div>
</template>

<script>
export default {
    name:'alert',
    data(){
        return {
            show:true,
            timer:null
        }
    },

    //时间   提示信息

    //props:[]

    props:{
        time:{
            type:Number,
            default:3
        },
        tip:{
            type:String,
            default:''
        }
    },

    mounted(){
        this.timer = setTimeout(() => {
            this.show = false;
        },this.time*1000)
    },
    watch:{
        show(newVal){
            if(!newVal){
                clearTimeout(this.timer)
            }
        }
    }
}
</script>

<style lang="scss">
    .alert-container{
        width:100%;
        height: 100%;
        background: rgba(0,0,0,.8);
        position:absolute;
        top:0;
        left:0;
        z-index:2;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .alert-con{
        // position: absolute;
        padding:10px;
        top:50%;
        left:50%;
        // transform: translate(-50%,-50%);
        // margin-left:-50px;
        // margin-top:-50px;
        background: #fff;
    }
</style>